Visualize first year students by level and mode of study using pyexcel and pyexcel-chart

Data source: HESA


In [14]:
import pyexcel as p

sheet = p.get_sheet(url='https://raw.githubusercontent.com/pyexcel/pyexcel-chart/master/hesa-students-data-2005-2015.csv")
sheet.top()


Out[14]:
pyexcel sheet:
Year Postgraduate part-timePostgraduate full-timeUndergraduate part-timeUndergraduate full-timeTotal
2005/06114,940 155,665 337,240 450,485 1,058,330
2006/07116,220 162,575 341,035 437,775 1,057,610
2007/08116,570 161,015 332,320 458,575 1,068,475
2008/09129,055 177,595 344,775 493,425 1,144,850

In [15]:
sheet.column[1]


Out[15]:
['Postgraduate part-time',
 '114,940',
 '116,220',
 '116,570',
 '129,055',
 '132,790',
 '127,750',
 '109,535',
 '102,890',
 '106,260',
 '107,950',
 '107,120']

In [16]:
def to_integer(cell):
    if ',' in cell:
        cell = cell.replace(',', '')
        cell = int(cell)
    return cell

sheet.column.format([1,2,3,4,5], to_integer)
#sheet.plot(chart_type='bar')
sheet.column[1]


Out[16]:
['Postgraduate part-time',
 114940,
 116220,
 116570,
 129055,
 132790,
 127750,
 109535,
 102890,
 106260,
 107950,
 107120]

In [17]:
del sheet.column[5]

In [18]:
sheet.plot(
    chart_type='stackedbar',
    title='First year students by level and mode of study 2005/06 to 2015/16',
    legend_at_bottom=True, legend_at_bottom_columns=2,
    range=(0, 1200000)
)


Out[18]:
First year students by level and mode of study 2005/06 to 2015/16001000001000002000002000003000003000004000004000005000005000006000006000007000007000008000008000009000009000001000000100000011000001100000120000012000002005/062006/072007/082008/092009/102010/112011/122012/132013/142014/152015/1611494044.55944055944056438.3834695512822005/06116220106.44755244755244438.142956730769242006/07116570168.33566433566432438.077191506410262007/08129055230.2237762237762435.73125200320512008/09132790292.1118881118881435.029443108974362009/10127750354.0435.97646233974362010/11109535415.88811188811184439.39907251602562011/12102890477.77622377622373440.6476722756412012/13106260539.6643356643357440.014447115384662013/14107950601.5524475524477439.69689503205132014/15107120663.4405594405595439.85285256410262015/1615566544.55944055944056387.536616586538462005/06162575106.44755244755244385.75719751602562006/07161015168.33566433566432385.918792067307662007/08177595230.2237762237762378.11152043269232008/09200880292.1118881118881372.33263621794872009/10207595354.0372.964921874999962010/11207665415.88811188811184379.79698918269232011/12203155477.77622377622373383.14162059294872012/13211875539.6643356643357380.23667668269232013/14209805601.5524475524477379.99052684294872014/15210945663.4405594405595380.088235176282072015/1633724044.55944055944056294.919451121794852005/06341035106.44755244755244291.128555689102542006/07332320168.33566433566432293.22082932692312007/08344775230.2237762237762279.95786258012822008/09334820292.1118881118881271.67426282051282009/10301025354.0277.394897836538462010/11278530415.88811188811184288.44063701923082011/12199940477.77622377622373307.399811698717942012/13175375539.6643356643357307.472153445512842013/14157835601.5524475524477310.910735176282062014/15148570663.4405594405595312.53513621794872015/1645048544.55944055944056146.905418669871782005/06437775106.44755244755244144.78965745192312006/07458575168.33566433566432144.61115184294872007/08493425230.2237762237762122.45954527243592008/09516770292.1118881118881111.659955929487182009/10509065354.0125.178467548076942010/11521605415.88811188811184138.094757612179482011/12466270477.77622377622373182.218525641025652012/13502230539.6643356643357180.149739583333342013/14513295601.5524475524477184.804977964743592014/15525490663.4405594405595185.878830128205122015/16First year students by level and mode of study 2005/06 to 2015/16Postgraduate part-timePostgraduate full-timeUndergraduate part-timeUndergraduate full-time